package com.dz51.module.index.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.math.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dz51.core.json.ViewResult;
import com.dz51.core.log4j.ILog4jManager;

@Controller
public class IndexController {

	@Autowired
	private ILog4jManager log4jManager;

	@RequestMapping("/index.html")
	public String indexHtml(Model model) {
		log4jManager.infoCustomLog(getClass().getSimpleName(), "index", "request /index.html");
		model.addAttribute("message", RandomUtils.nextInt(10000));
		return "hello";
	}

	@RequestMapping("/index.json")
	@ResponseBody
	public String indexGson(Model model) {
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("name", "哈哈");
		return ViewResult.newInstance().success().data(data).json();
	}
}